<%@ page language="java" contentType="text/html; charset=utf-8"
    pageEncoding="utf-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>信息录入功能</title>
</head>
<body>
<form action="" name="myform" onSubmit="return check()">

手机号：<input type="text" id="cellPhoneNum" onblur="registerErrorC()">
<p id="errorCellPhoneNum" style="display:none">手机号长度要等于11个数字</p>
<br>
邮箱：<input type="text"id="emailText" onblur="registerErrorE()">
<p id="errorEmailText" style="display:none">Email地址错误</p>
<br>
密码：<input name="pwd1" type="password">
<br>
确认密码：<input name="pwd2" type="password">
<br>
<input name="role" type="radio" value="学生"/>学生
<br><br>
<input name="role" type="radio" value="老师"/>老师

<br>多选
一<input type="checkbox">
二<input type="checkbox" checked="checked">
三<input type="checkbox">
四<input type="checkbox">
<br>

<input type="submit" value="注册">
</form>
<script type="text/javascript">

function registerErrorC(){
	
	var x=document.getElementById("cellPhoneNum").value.length;
	if(x!=11){
	document.getElementById("errorCellPhoneNum").style.display="inline";
	document.getElementById("errorCellPhoneNum").style.color="red";
	}
	 else{
		   document.getElementById("errorCellPhoneNum").style.display="none";
	   }

	
}
function registerErrorE(){
	//邮箱  XXXXXX@XXXX.XXXX
	var sReg = /[_a-zA-Z\d\-\.]+@[_a-zA-Z\d\-]+(\.[_a-zA-Z\d\-]+)+$/;
   if (!sReg.test(document.getElementById("emailText").value) )
   {
	   document.getElementById("errorEmailText").style.display="inline";
		document.getElementById("errorEmailText").style.color="red";

	}
   else{
	   document.getElementById("errorEmailText").style.display="none";
   }

	
}
function check()
{
	if(document.myform.role[0].checked|document.myform.role[1].checked){
		return true
	}    
    else{
    	 alert("请选择角色");
         return false
    }   
}




</script>
<!-- 1.要是字符长度的验证

2.有邮箱格式的验证

3.有单选，多选

4.如果输入错误格式，要有红色字体的提示 -->
</body>
</html>